attribute vec3 aPosition;
attribute vec3 aNormal;
attribute vec3 aTexture;
attribute vec2 uv;

// Flags
uniform bool uFlipNormal;
uniform bool uTextured;

uniform mat4 uProjMatrix;
uniform mat4 uViewMatrix;
uniform mat4 uModelMatrix;
uniform mat4 uNormalMatrix;

varying vec2 vTextCoord;
varying vec3 vLightVector;
varying vec3 vNormal;

void main() {
    vec4 skinnedPos = vec4(aPosition, 1.0);
    vec4 mPosition = uModelMatrix * skinnedPos;
    vec4 mNormal = vec4(aNormal, 1.0);

    if (uFlipNormal) {
        mNormal = -1.0 * mNormal;
    }

    vTextCoord = uv;

    vNormal = normalize((uNormalMatrix * mNormal).xyz);
    vec3 mLightPosition = vec3(4.0, 0.0, 2.0);
    vLightVector = normalize(mLightPosition - mPosition.xyz);

    gl_Position = uProjMatrix * uViewMatrix * mPosition;
}

